package org.uim.cricket.analyzer.validate.impl;

import java.util.ArrayList;
import java.util.List;

import org.uim.cricket.analyzer.validate.ValidatableMatch;
import org.uim.cricket.analyzer.validate.ValidatorList;

public class QueueValidatorList implements ValidatorList {

	private List<ValidatableMatch> validators = new ArrayList<ValidatableMatch>();
	
	@Override
	public ValidatableMatch peekAnalyzer() throws Exception {
		if (this.validators.size() <= 0) {
			throw new Exception("Validator list is underflow!");
		}
		return validators.get(0);
	}

	@Override
	public ValidatableMatch popAnalyzer() throws Exception {
		if (this.validators.size() <= 0) {
			throw new Exception("Validator list is underflow!");
		}
		ValidatableMatch temp = this.validators.get(0);
		this.validators.remove(0);
		return temp;
	}

	@Override
	public boolean isEmpty() {
		return (this.validators == null || this.validators.size() <= 0);
	}

	@Override
	public boolean pushAnalyzer(ValidatableMatch itemObject) {
		this.validators.add(itemObject);
		return true;
	}
	
	public void setValidators(List<ValidatableMatch> validators) {
		this.validators = validators;
	}
	
	public List<ValidatableMatch> getValidators() {
		return validators;
	}

}
